#include<iostream> 
using namespace std;

struct ListNode {
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
    	if(!head || !head->next)return head;
        ListNode *ans = new ListNode();
		ans->next = head;
		ListNode *pre = ans->next, *latter, *res = new ListNode();
		ans = head->next;
		while(pre && pre->next){
			res->next = pre->next;
			latter = pre->next;
			pre->next = latter->next;
			res = pre;
			latter->next = pre;
			pre = pre->next;
		} 
		return ans;
    }
};

int main(){
	return 0;
} 
//2020.10.5

